package edu.pku.sei.mte.runtime.rulebased;

import edu.pku.sei.mte.mtemodel.mtmodel.rulebased.RBTransformation;
import edu.pku.sei.mte.mtemodel.mtmodel.rulebased.Rule;
import edu.pku.sei.mte.runtime.Context;


public class RBTContext extends Context {
	private RBTransformation transformation;
	private Rule rule;
	
	public RBTransformation getTransformation() {
		return transformation;
	}
	public void setTransformation(RBTransformation transformation) {
		this.transformation = transformation;
	}
	
	@Override
	public RBTEnvironment getEnvironment() {
		// TODO Auto-generated method stub
		return (RBTEnvironment) super.getEnvironment();
	}
	public RBTContext getChildRuleContext(){
		RBTContext context = new RBTContext();
		context.setEnvironment(this.getEnvironment());
		context.setTransformation(this.getTransformation());
		context.setParentContext(this);
		return context;
	}
	public Rule getRule() {
		return rule;
	}
	public void setRule(Rule rule) {
		this.rule = rule;
	}
	
	@Override
	public RBTContext getParentContext() {
		// TODO Auto-generated method stub
		return (RBTContext) super.getParentContext();
	}
	@Override
	public boolean equals(Object arg0) {
		if(arg0 == this)
			return true;
		if(arg0 instanceof RBTContext == false)
			return false;
		RBTContext arg1 = (RBTContext)arg0;
		if(this.getEnvironment() != arg1.getEnvironment() || this.transformation != arg1.transformation || this.rule != arg1.rule)
			return false;
		return super.equals(arg0);
	}
}
